import Vue from 'vue'
const vue = new Vue()

const TokenKey = 'User-Token'

export function getToken() {
  return vue.$pt.getStorageSync(TokenKey)
}

export function setToken(token) {
  return vue.$pt.setStorageSync(TokenKey, token)
}

export function clearStorageSync() {
  // 清除所有缓存
  return vue.$pt.clearStorageSync()
}

export function setMemberId(memberId) {
  vue.$pt.setStorageSync('memberId', memberId)
  // 储存响应式缓存
  vue.$store.commit('setMemberId', memberId)
}

export function setCustomerId(customerId) {
  vue.$pt.setStorageSync('customerId', customerId)
  // 储存响应式缓存
  vue.$store.commit('setCustomerId', customerId)
}

export function setPhone(phone) {
  vue.$pt.setStorageSync('phone', phone)
  // 储存响应式缓存
  vue.$store.commit('setPhone', phone)
}

export function setNickName(nickName) {
  vue.$pt.setStorageSync('nickName', nickName)
  // 储存响应式缓存
  vue.$store.commit('setNickName', nickName)
}

// 支付类型
export function setPayMethod(payMethod) {
  vue.$pt.setStorageSync('payMethod', payMethod)
  // 储存响应式缓存
  vue.$store.commit('setPayMethod', payMethod)
}

// 跨境增值功能
export function setCbFlag(cbFlag) {
  vue.$pt.setStorageSync('cbFlag', cbFlag)
  // 储存响应式缓存
  vue.$store.commit('setCbFlag', cbFlag)
}

export function setVisitorId(visitorId) {
  vue.$pt.setStorageSync('visitorId', visitorId)
  // 储存响应式缓存
  vue.$store.commit('setVisitorId', visitorId)
}

export function setEnterpriseId(enterpriseId) {
  vue.$pt.setStorageSync('enterpriseId', enterpriseId)
  // 储存响应式缓存
  vue.$store.commit('setEnterpriseId', enterpriseId)
}

export function setApplyWholesaleAuthority(applyWholesaleAuthority) {
  vue.$pt.setStorageSync('applyWholesaleAuthority', applyWholesaleAuthority)
  // 储存响应式缓存
  vue.$store.commit('setApplyWholesaleAuthority', applyWholesaleAuthority)
}

export function setVeekrayStatus(veekrayStatus) {
  vue.$pt.setStorageSync('veekrayStatus', veekrayStatus)
  // 储存响应式缓存
  vue.$store.commit('setVeekrayStatus', veekrayStatus)
}

export function setStoreCardFlag(storeCardFlag) {
  vue.$pt.setStorageSync('storeCardFlag', storeCardFlag)
  vue.$store.commit('setStoreCardFlag', storeCardFlag)
}
export function setMemberNature(memberNature) {
  vue.$pt.setStorageSync('memberNature', memberNature)
  vue.$store.commit('setMemberNature', memberNature)
}

// 是否显示购买名片按钮
export function setShowBuyCard(showBuyCard) {
  vue.$pt.setStorageSync('showBuyCard', showBuyCard)
  // 储存响应式缓存
  vue.$store.commit('setShowBuyCard', showBuyCard)
}

export function setAppInfo(appInfo) {
  vue.$pt.setStorageSync('appInfo', appInfo)
  // 储存响应式缓存
  vue.$store.commit('setAppInfo', appInfo)
}

// 购物车角标
export function setCartBadge(cartBadge) {
  vue.$pt.setStorageSync('cartBadge', cartBadge)
  vue.$store.commit('setCartBadge', cartBadge)
}

// 快速购买商品列表
export function setFastGoods(fastGoods) {
  vue.$pt.setStorageSync('fastGoods', fastGoods)
  vue.$store.commit('setFastGoods', fastGoods)
}

// 快速购买商品列表
export function setWholesaleAuthority(wholesaleAuthority) {
  vue.$pt.setStorageSync('wholesaleAuthority', wholesaleAuthority)
  vue.$store.commit('setWholesaleAuthority', wholesaleAuthority)
}

// 底部导航列表
export function setNavList(navList) {
  vue.$pt.setStorageSync('navList', navList)
  vue.$store.commit('setNavList', navList)
}

// 分类链接
export function setCategoryInfo(categoryInfo) {
  vue.$pt.setStorageSync('categoryInfo', categoryInfo)
  // 储存响应式缓存
  vue.$store.commit('setCategoryInfo', categoryInfo)
}

// 是否开启批发商强制完善个人信息：0-关闭，1-开启
export function setIsPerfectionInfo(isPerfectionInfo) {
  vue.$pt.setStorageSync('isPerfectionInfo', isPerfectionInfo)
  // 储存响应式缓存
  vue.$store.commit('setIsPerfectionInfo', isPerfectionInfo)
}
